#include<stdio.h>

#define N 10

void insert_num(int arr[], int n, int num);
int main(int argc, char *argv[]){
	int num;
	int arr[N] = {1, 3, 5, 7, 15, 17, 21, 23, 30, 51};
	for(int i = 0; i < N; i++){
		printf("%d ", arr[i]);
	}
	printf("\n");
	printf("请输入要插入的数字：");
	scanf("%d", &num);
	insert_num(arr, N, num);
	printf("\n");

	for(int i = 0; i < N; i++){
		printf("%d ", arr[i]);
	}
	printf("\n");

	return 0;
}
int find_index(int arr[],int n, int num){
	for(int i = 0; i < n; i++){
		if(arr[i] == num){
			return i + 1;
		}else if(arr[i] < num){
			if(i == n-1){
				return i+1;
			}else if(arr[i+1] > num){
				return i+1;
			}
		}else if(arr[i] > num && i == 0){
			return i;
		}
	}
}
void insert_num(int arr[], int n, int num){
	int i;
	int index;
	index = find_index(arr, n, num);
	for(i = n-1; i > index; i--){
		arr[i] = arr[i-1];
	}
	if(index < n){
		arr[index] = num;
	}
	return;
}


